package com.lhl.shallow;

import lombok.Data;

/**
 * 浅克隆具体原型类
 * @author Liu Hanlin
 * @create 2024-09-29 0:18
 */
@Data
public class ShallowConcretePrototype implements Cloneable{

    public String field1;

    public Field2 field2;

    @Override
    public ShallowConcretePrototype clone(){

        ShallowConcretePrototype shallowConcretePrototype = null;

        try {
            shallowConcretePrototype = (ShallowConcretePrototype) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }

        return shallowConcretePrototype;
    }

    public ShallowConcretePrototype(String field1, Field2 field2) {
        this.field1 = field1;
        this.field2 = field2;
    }

}
